<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div>
			@implementation OObject <br />
<br />
- (id)init {<br />
    self = [super init];<br />
    if (!self) {<br />
        CCLOG(@"%@   初始化失败", NSStringFromClass([self class]));<br />
    }<br />
    return self;<br />
}<br />
<br />
+ (id)parseFromDictionary:(NSDictionary *)sender {<br />
    if (![sender isKindOfClass:[NSDictionary class]]) {<br />
        CCLOG(@"Product +++++++++++++++MODEL+++++++++++++ 解析非字典类");<br />
        return [self init];<br />
    }<br />
    return [[[[self class] alloc] init] parseFromDictionary:sender];<br />
}<br />
<br />
- (id)parseFromDictionary:(NSDictionary *)sender {<br />
    if (![self init]) {<br />
        CCLOG(@"Product +++++++++++++++MODEL+++++++++++++ 初始化失败");<br />
    }<br />
    if (![sender isKindOfClass:[NSDictionary class]]) {<br />
        CCLOG(@"Product +++++++++++++++MODEL+++++++++++++ 解析非字典类");<br />
        return self;<br />
    }<br />
    return self;<br />
}<br />
<br />
<br />
- (NSMutableDictionary *)dictionaryValue {<br />
    NSMutableDictionary *dictionaryValue = [[NSMutableDictionary alloc] init];<br />
    return dictionaryValue;<br />
}<br />
<br />
- (BOOL)saveForKey:(NSString *)sender {<br />
    NSDictionary *dictionaryValue = [self dictionaryValue];<br />
    [[NSUserDefaults standardUserDefaults] setObject:dictionaryValue forKey:sender];<br />
    BOOL saveResult = [[NSUserDefaults standardUserDefaults] synchronize];<br />
    return saveResult;<br />
}<br />
<br />
+ (id)findForKey:(NSString *)sender {<br />
    if (![[NSUserDefaults standardUserDefaults] objectForKey:sender]) {<br />
        return nil;<br />
    }<br />
    NSDictionary *findDictionary = [[NSUserDefaults standardUserDefaults] dictionaryForKey:sender];<br />
    if (![findDictionary isKindOfClass:[NSDictionary class]]) {<br />
        CCLOG(@"Product +++++++++++++++MODEL+++++++++++++ 查找数据出错");<br />
        return nil;<br />
    }<br />
    OObject *findResult = [[self class] parseFromDictionary:findDictionary];<br />
    return findResult;<br />
}<br />
<br />
<br />
- (id)copyWithZone:(NSZone *)zone {<br />
    OObject *copyObject = [[self class] allocWithZone:zone];<br />
    [self copyOperationWithObject:copyObject];<br />
    return copyObject;<br />
}<br />
<br />
- (void)copyOperationWithObject:(id)object {<br />
}<br />
<br />
<br />
static OObject *shareObject = nil;<br />
+ (id)shareInstance {<br />
    static dispatch_once_t onceToken;<br />
    dispatch_once(&onceToken, ^{<br />
        shareObject = [[[self class] alloc] init];<br />
    });<br />
    return shareObject;<br />
}<br />
<br />
+(NSString *)initialDB {<br />
    static dispatch_once_t onceToken;<br />
    dispatch_once(&onceToken, ^{<br />
        NSString *dirPath = [NSString stringWithFormat:@"%@/%@", [NSSearchPathForDirectoriesInDomains(NSCachesDirectory , NSUserDomainMask , YES) lastObject], @"DB"];<br />
        BOOL isDir = NO;<br />
        bool existed = [[NSFileManager defaultManager] fileExistsAtPath:dirPath isDirectory:&isDir];<br />
        if (!(isDir == YES && existed == YES)) {<br />
            [[NSFileManager defaultManager] createDirectoryAtPath:dirPath withIntermediateDirectories:YES attributes:nil error:nil];<br />
        }<br />
        ((OObject *)[OObject shareInstance]).dbPath = [NSString stringWithFormat:@"%@/database.db", dirPath];<br />
    });<br />
    return ((OObject *)[OObject shareInstance]).dbPath;<br />
}<br />
<br />
@end<br />
		</div>
	</body>
</html>
